package com.mskj.zxmy.controller;

import com.github.pagehelper.PageInfo;
import com.mskj.zxmy.common.Result;
import com.mskj.zxmy.dto.ReportQueryDTO;
import com.mskj.zxmy.entity.ReportMain;
import com.mskj.zxmy.service.ReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/report")
@Tag(name = "报工接口")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @PostMapping("/report/list")
    @Operation(summary = "报工列表查询不筛选")
    public Result<PageInfo<ReportMain>> getReportList(@RequestBody ReportQueryDTO query) {
        return Result.success(reportService.getReportList(query));
    }

    // 报工单详情
    @GetMapping("/detail/{id}")
    @Operation(summary = "根据id查询报工详情")
    public Result<ReportMain> getReportDetail(@PathVariable Integer id) {
        return Result.success(reportService.getReportDetail(id));
    }

    // 报工单列表（支持筛选）
    @PostMapping("")
    @Operation(summary = "报工单列表查询")
    public Result<PageInfo<ReportMain>> getReportListByQuery(@RequestBody ReportQueryDTO query) {
        return Result.success(reportService.getReportListByQuery(query));
    }

    @GetMapping("category")
    @Operation(summary = "物料类别")
    public Result<List<String>> getCategoryList() {
        return Result.success(reportService.getCategoryList());
    }

    @GetMapping("Brand")
    @Operation(summary = "品牌")
    public Result<List<String>> getBrandList() {
        return Result.success(reportService.getBrandList());
    }

}